package main

import (
	"github.com/kataras/iris/v12"
	"github.com/kataras/iris/v12/mvc"
	"github.com/micro/go-micro/v2"
	"github.com/micro/go-micro/v2/client/selector"
	"github.com/micro/go-micro/v2/web"
	"github.com/micro/go-plugins/registry/etcdv3/v2"
	"gomicro/formJsonMicro/fjmClient/controller"
	_ "gomicro/formJsonMicro/fjmClient/controller"
	"gomicro/formJsonMicro/fjmClient/wrappers"
	"log"
)

func main() {

	microService := micro.NewService(
		micro.Selector(selector.NewSelector(selector.Registry(etcdv3.NewRegistry()),
			selector.SetStrategy(selector.RoundRobin),)),
		micro.Registry(etcdv3.NewRegistry()),
		//micro.Registry(util.EtcdRegistry),
		micro.WrapClient(wrappers.NewLogWrapper),
		micro.WrapClient(wrappers.NewClientWrapper()),

	)

	service := web.NewService(
		web.Name("go.micro.api.member"),
		web.Registry(etcdv3.NewRegistry()),
	)

	microService.Init()

	service.Init()

	app := iris.New()
	mvc.New(app).Handle(new(controller.MemberMicroController))
	app.Run(iris.Addr(":0004"))

	service.Handle("/", app)

	if err := service.Run(); err != nil {
		log.Fatal(err)
	}

}

/*
自定义负载均衡：创建结构体，实现方法，初始化 //micro.Selector(&结构体实例),
*/